package com.vrv.common.resolver.dispatcher;

import android.content.Context;

import com.vrv.common.resolver.RequestParameter;
import com.vrv.common.resolver.Response;

public class RequestManager {

    private static final RequestManager requestManager = new RequestManager();

    private static Context mContext;

    private RequestManager() {
    }

    /**
     * handler
     *
     * @param dbType
     * @param parameter
     * @param detailKeys
     * @return
     */
    public Response handler(RequestParameter parameter, String[] detailKeys) {

        RequestState requestState = null;
        DbType dbType = parameter.getDbType();

        switch (dbType) {

        case remotePageDb:
            requestState = new RemoteRequestHandler();
            break;
        case localPageDb:
            requestState = new LocalityPageRequestHandler();
            break;
        case localChartDb:
            requestState = new LocalityChartRequestHandler();
            break;
        }

        return requestState.handler(RequestManager.mContext, parameter, detailKeys);

    }

    /**
     * 获取单例RequestManager实例
     *
     * @return
     */
    public static RequestManager getInstance(Context mContext) {
        RequestManager.mContext = mContext;
        return requestManager;
    }

}
